package m4;

import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;
/*
     路由模式
 */
@Component
public class Consumer {
    //rabbit监听-->queue绑定-->value/exchange/key
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue, // 随机命名,非持久,独占,自动删除
            exchange = @Exchange(name = "direct_logs", declare = "false") ,//declare = "false":使用已经存在的交换机而不创建
            key = {"error"}
    ))
    public void receive1(String s) {
        System.out.println("消费者1收到： "+s);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            exchange = @Exchange(name = "direct_logs", declare = "false"),
            key = {"error"}
    ))
    public void receive2(String s) {
        System.out.println("消费者2收到： "+s);
    }



}
